package guo.service;

import guo.entity.Student;
import guo.mapper.StudentMapper;
import guo.util.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author: gsq
 * @description: TODO
 * @date: 2024/5/11 14:56
 * @version: 1.0
 */
@Service
public class StudentService {

    @Autowired
    private StudentMapper studentMapper;
    public List<Map> getListByExcel(InputStream is, String fileName) throws IOException {

        try{
            List<Map> studentList = new ExcelUtil(new Student()).AnalysisExcel(is, fileName);
            return studentList;
        }catch (Exception e){
            e.printStackTrace();
        }
        return new ArrayList<>();
    }
    public Boolean batchImportStuInfo(List<Map> list){
        Integer flag = studentMapper.batchImportStuInfo(list);
        if (flag > 0){
            return true;
        } else return false;
    }

}
